package com.mall.advertising.controller;

import java.util.List;

import com.mall.advertising.domain.TCrow;
import com.mall.advertising.service.ITCrowService;
import com.mall.common.core.domain.Result;
import com.mall.common.core.web.controller.BaseController;
import com.mall.common.log.annotation.Log;
import com.mall.common.log.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 人群Controller
 *
 * @date 2025-02-14
 */
@RestController
@RequestMapping("/crow")
public class TCrowController extends BaseController
{
    @Autowired
    private ITCrowService tCrowService;

    /**
     * 查询人群列表
     */
    @GetMapping("/list")
    public Result<List<TCrow>>  list(TCrow tCrow)
    {
        startPage();
        List<TCrow> list = tCrowService.selectTCrowList(tCrow);
        return Result.success(list);
    }

    /**
     * 获取人群详细信息
     */
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(tCrowService.selectTCrowById(id));
    }

    /**
     * 新增人群
     */
    @Log(title = "人群", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody TCrow tCrow)
    {
        return toAjax(tCrowService.insertTCrow(tCrow));
    }

    /**
     * 修改人群
     */
    @Log(title = "人群", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody TCrow tCrow)
    {
        return toAjax(tCrowService.updateTCrow(tCrow));
    }

    /**
     * 删除人群
     */
    @Log(title = "人群", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(tCrowService.deleteTCrowByIds(ids));
    }





}
